<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>系统管理-菜单</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" /></head>
	<style type="text/css">
		#entityList thead tr{background-color: #f2f2f2;}
		#entityList thead th,#entityList thead td{height: 36px;color: rgb(102, 102, 102); text-align: center; padding: 0px 5px; line-height: 36px;font-size: 14px; font-weight: normal; border-width: 1px;border-style: solid;border-color: #e6e6e6;}
		#entityList tbody td{height: 36px;color: rgb(102, 102, 102); padding: 0px 5px; line-height: 36px;font-size: 14px; font-weight: normal; border-width: 1px;border-style: solid;border-color: #e6e6e6;}
	</style>
<body class="childrenBody">
<form class="layui-form">
	<blockquote class="layui-elem-quote quoteBox" id="tool">
		<div class="layui-inline">
			<label class="layui-input-inline">名称</label>
			<label class="layui-input-inline">
				<input type="text" class="layui-input" name="menuName" placeholder="请输入名称" /></label>
			<a class="layui-btn search_btn" lay-submit="" lay-filter="seacherTreeBtn">搜索</a></div>
		<div class="layui-inline">
			<a class="layui-btn layui-btn-normal addBtn" data-title="添加" data-url="/sysMenu/getEntity">添加</a></div>
	</blockquote>
	<table id="entityList" lay-filter="entityList"></table>
</form>
<script type="text/html" id="entityBar">
	<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit">编辑</a>
	<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
</script>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">
    layui.use(['jquery','pageUtil','form'], function(){
        var $=layui.jquery,
        form = layui.form,
        pageUtil = layui.pageUtil;
        var treeGridTable=null;
        pageUtil.initDict("sys_menu_type,sys_menu_grade", function (dictData) {
            var url="/sysMenu/list";
            var cols=[
                {type:'numbers',
                    width: '5%'},
                {
                    field: 'menuName',
                    title: '菜单名称',
                    width: '20%'
                },{
                    field: 'menuUrl',
                    title: '菜单地址',
                    width: '20%'
                },{
                    field: 'menuGrade',
                    title: '菜单级别', templet:function(d){
                        return pageUtil.aceeptDictContentName(dictData,"sys_menu_grade",d.menuGrade);
                    },
                    align:'center',
                    width: '7%'
                },{
                    field: 'sort',
                    title: '排序',
                    align:'center',
                    width: '5%'
                },{
                    field: 'menuCode',
                    title: '菜单code',
                    width: '7%'
                },{
                    field: 'type',
                    title: '菜单类型', templet:function(d){
                        return pageUtil.aceeptDictContentName(dictData,"sys_menu_type",d.menuType);
                    },
                    align:'center',
                    width: '8%'
                },{
                    field: 'permission',
                    title: '权限标识',
                    width: '13%'
                },
                {width:300,title: '操作', align:'left',templet:function(d){
                    //1、目录，2、菜单，3、按钮
                	if(d.menuType == "1"){
                	    return '<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="add">添加</a>'+
						'<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit">编辑</a>'+
                            '<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>';
					}else{
                        return '<a class="layui-btn layui-btn-disabled layui-btn-sm">添加</a>'+
                            '<a class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="edit">编辑</a>'+
                            '<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>';
					}
                }}
            ];
            treeGridTable = pageUtil.initTreeGridDate(cols,url,true);
        });
        pageUtil.initTreeGridOn(function (obj) {
            debugger
            if(obj.event === 'del'){//删除行
                pageUtil.delete("确定删除【"+obj.data.menuName+"】菜单吗？","/sysMenu/delete", {"id":obj.data.id,"_method":"DELETE"},function (data) {
                    pageUtil.initTreeGridQuery("");
                });
            }else if(obj.event==="add"){//添加行
                pageUtil.editPopup("添加","/sysMenu/getEntity?parentId="+obj.data.id);
            }else if(obj.event==="edit"){//编辑行
                pageUtil.editPopup("编辑","/sysMenu/getEntity?id="+obj.data.id+"&parentId="+obj.data.parentId);
            }
        })
        /**
         * 工具栏-搜索
         */
        form.on('submit(seacherTreeBtn)', function (data) {
            pageUtil.initTreeGridQuery(data.field);
            return false;
        });

    });

	</script>
</body>

</html>